home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11881 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question about exemplars
  5. Date: Sat, 16 Mar 1996 21:10:33 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4ifamt$5q0@news.halcyon.com>
  8. References: <31475C8B.41C6@corp.sgi.com>
  9. NNTP-Posting-Host: blv-pm3-ip13.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Vishwanath Raman <vish@corp.sgi.com> wrote:
  13.  
  14. >I am building a message library using Exemplars. I write objects from a
  15. >given class hierarchy into a buffer ( contiguously ) and then send the
  16. >buffer accross to a server/peer. I bring the objects back to 'life' by
  17. >invoking a virtual MakeObject method defined through the hierarchy.
  18.  
  19. >The problem is in trying to regenerate a message when the compilers used
  20. >in creating the client/peer and server/peer programs are DIFFERENT.
  21.  
  22. >This I assume is because of the way VTable pointers are stored within
  23. >the class address space.
  24.  
  25. >Any ideas to overcome this problem. Exemplars constitute a cool way of
  26. >regenerating hierarchy objects without parsing...
  27.  
  28. >A standardisation for the way class objects are stored in memory seems
  29. >to be in order???
  30.  
  31. >Thanks a mill for any feedback in advance, Vish
  32.  
  33. >-- 
  34. >Vishwanath Raman
  35. >vish@corp.sgi.com
  36.  
  37. No, the vtable thing is a non-issue.   If you pass pointers across
  38. process boundaries, you need all sorts of special marshalling
  39. mechanisms; this doesn't sound like anything you need.  Meanwhile,
  40. passing function pointers across process boundaries does not RPC make!
  41. Don't try it.  
  42.  
  43. Write the objects into a stream the same way you'd write them to disk.
  44. The objects don't exist in this stream, but are created normally at
  45. the other end of the pipe just like they would be if loaded from disk.
  46.  
  47. The save and load, of course, goes member-by-member.  The first things
  48. written are some kind of type identifier or other piece of data you
  49. can bang against your list of exemplar objects when looking for the
  50. right class to use.  
  51.  
  52. With member-by-member persistence, you avoid structure packing
  53. problems that a blanket Writefile( &myobj, sizeof(myobj)) would
  54. otherwise cause.  You only need to agree that member X uses N bytes.
  55.  
  56. You're using the exemplar idiom found in Copelein's "Advanced C++
  57. Styles and Idioms," are you?
  58.  
  59.                         --Norm 
  60.  
  61.